package IT05;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;

public class ListDemo03 {
    public static void main(String[] args) {
        //创建集合对象
        ArrayList<String> array = new ArrayList<>();
        array.add("hello");
        array.add("world");
        array.add("java");
        //遍历
        for(String s : array){
            System.out.println(s);
        }
/*
        for(int i = 0;i<array.size();i++){
            System.out.println(array.get(i));
        }
        Iterator<String> it = array.iterator();
        while (it.hasNext()){
        String s = it.next();
            System.out.println(s);
        }
        */
        System.out.println("-------");
        LinkedList<String> linkedList = new LinkedList<>();
        linkedList.add("hello");
        linkedList.add("world");
        linkedList.add("java");
        for(String s : linkedList){
            System.out.println(s);
        }
    }
}
